#ifndef LIST_H
#define LIST_H

#include <stdint.h>
#include <stdbool.h>

typedef enum {
    CLIST_ERR_SUCESS = 0,
    CLIST_ERR_MEM,
    CLIST_ERR_NULL_PTR,
    CLIST_ERR_LIST_EMPTY
} clist_err_t;

typedef struct node node_t;
struct node{
    void *data;
    node_t *next;
};

typedef struct clist clist_t;
struct clist{
    node_t *head;
    node_t *tail;
    uint32_t len;

    int (*node_add)(clist_t *list, void *data);
    void *(*node_remove)(clist_t *list);
    void *(*node_remove_by_data)(clist_t *list, void *data,
                                 bool (*traverse)(void *node_data, void *data));
    int (*node_insert)(clist_t *list, void *data, void *ref_data,
                       bool (*traverse)(void *node_data, void *data), bool previous);
    void (*list_traverse)(clist_t *list, void *data, void (*traverse)(void *node_data, void *data));
    void (*list_del)(clist_t *list, void (*data_free)(void *data));
} ;

clist_t * clist_new();
void clist_del(clist_t *list, void (*data_free)(void *data));

#endif // LIST_H
